package com.wengzw.service;
import com.wengzw.dao.CustomerMapper;
import com.wengzw.dao.UserMapper;
import com.wengzw.po.Customer;
import com.wengzw.po.User;
import com.wengzw.vo.CustomerVo;
import com.wengzw.vo.UserVo;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import javax.annotation.Resource;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    /**
     * 登陆
     * @param user_name
     * @param user_password
     * @return
     */
    @Resource
    private UserMapper userMapper;
    public User login(String user_name, String user_password) {
        //调用根据用户名查询用户信息
        User user = userMapper.findUserByLoginName(user_name);
        // String newPassword = PasswordUtil.md5(user_password,user.getUser_name(),5);
        if(user.getUser_name().equals(user_name) &&  user.getUser_password().equals(user_password)){
            return user;
        }
        return null;
    }
   
    
    public List<User> findUserList(UserVo UserVo) {
        return userMapper.findUserList(UserVo);
    }
    //添加客户
    public int addUser(User user){
        return userMapper.addUser(user);
    }
    //修改客户
    
    public int updateUser(User user){
        return userMapper.updateUser(user);
    }

    //删除客户
   
    public int deleteById(Integer user_id){
        return userMapper.deleteById(user_id);
    }

    //根据id查询用户
    @Override
    public User findUserByID(Integer user_id) {
        return userMapper.findUserByID(user_id);
    }
}

